import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {HttpService} from "../../providers/HttpService";
import {DomSanitizer} from "@angular/platform-browser";

/**
 * Generated class for the InfoDetailPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-info-detail',
  templateUrl: 'info-detail.html',
})
export class InfoDetailPage {

    news_content: any = null;

    constructor(public navCtrl: NavController, public navParams: NavParams,
                private sanitize: DomSanitizer,
                private httpService: HttpService) {
    }

    ionViewDidLoad() {
        let newsData = this.navParams.get('news');
        this.news_content = this.sanitize.bypassSecurityTrustResourceUrl(newsData.appNewsUrl);
    }

    getNewsById(id) {
        this.httpService.instance()
            .setUrl('/gold/getNews')
            .setQuery({
                newsId: id
            })
            .getRequest()
            .then(res => {
                if (res.status == 0) {
                    console.log(res.data.result);
                } else {
                    console.log(res.msg);
                }
            });
    }
}
